<table class="member-grid">
  <thead>
    <tr>
      <th><{t}>订单号<{/t}></th>
      <th><{t}>金额<{/t}></th>
      <th><{t}>下单时间<{/t}></th>
      <th><{t}>订单状态<{/t}></th>
      <th><{t}>支付方式<{/t}></th>
      <th><{t}>操作<{/t}></th>
    </tr>
  </thead>
  <{if $orders}>
  <{foreach from=$orders item=order name=orders key="key"}>
  <tbody class="<{if !$is_orders}>fold<{else}>unfold<{/if}><{if $smarty.foreach.orders.iteration == 1}> first<{/if}>">
    <tr>
      <td class="order" width="28%"><a href="<{link app=b2c ctl=site_member act=orderdetail arg0=$order.order_id arg1=$archive}>"><{$order.order_id}></a><span class="handle action-view-goods">[<{$order.itemnum}> <{t}>商品<{/t}>]<i class="icon arrow-down">&#x36;</i><i class="icon arrow-up">&#x37;</i></span></td>
      <td class="price"><{$order.cur_amount|cur_odr:$order.currency:false:true}></td>
      <td class="datetime"><{$order.createtime|cdate:FDATE_STIME}></td>
      <td class="status">
        <{switch from=$order.status}>
        <{case value='finish'}><{t}>已完成<{/t}>
        <{case value='dead'}><{t}>已作废<{/t}>
        <{case}>
        <{switch from=$order.pay_status}>
        <{case value='1'}><{t}>已付款<{/t}>
        <{switch from=$order.ship_status}>
        <{case value='1'}><{t}>[已发货]<{/t}>
        <{case value='2'}><{t}>[部分发货]<{/t}>
        <{case value='3'}><{t}>[部分退货]<{/t}>
        <{case value='4'}><{t}>[已退货]<{/t}>
        <{case}><{t}>[正在备货]<{/t}>
        <{/switch}>
        <{case value='2'}><{t}>已付款至担保方<{/t}>
        <{case value='3'}>
         <!--普通订单-->
        <{if $order.promotion_type != 'prepare'}>
          <a href="<{link app=b2c ctl=site_paycenter arg0=$order.order_id}>"><{t}>等待补款<{/t}></a>
        <{/if}>
         <!--预售订单-->
        <{if  $order.promotion_type == 'prepare'}>
        <a href="#"><{t}>等待补款<{/t}></a>
        <{/if}>
        <{switch from=$order.ship_status}>
        <{case value='1'}><{t}>[已发货]<{/t}>
        <{case value='2'}><{t}>[部分发货]<{/t}>
        <{case value='3'}><{t}>[部分退货]<{/t}>
        <{case value='4'}><{t}>[已退货]<{/t}>
        <{/switch}>
        <{case value='4'}><{t}>部分退款<{/t}>
        <{switch from=$order.ship_status}>
        <{case value='0'}><{t}>[未发货]<{/t}>
        <{case value='1'}><{t}>[已发货]<{/t}>
        <{case value='2'}><{t}>[部分发货]<{/t}>
        <{case value='3'}><{t}>[部分退货]<{/t}>
        <{case value='4'}><{t}>[已退货]<{/t}>
        <{/switch}>
        <{case value='5'}><{t}>已退款<{/t}>
        <{switch from=$order.ship_status}>
        <{case value='0'}><{t}>[未发货]<{/t}>
        <{case value='1'}><{t}>[已发货]<{/t}>
        <{case value='2'}><{t}>[部分发货]<{/t}>
        <{case value='3'}><{t}>[部分退货]<{/t}>
        <{case value='4'}><{t}>[已退货]<{/t}>
        <{/switch}>
        <{case}>
         <!--普通订单-->
        <{if $order.promotion_type != 'prepare'}>
          <{if $order.payinfo.pay_app_id != '-1'}><a href="<{link app=b2c ctl=site_paycenter arg0=$order.order_id}>"><{/if}><{t}>等待付款<{/t}><{if $order.payinfo.pay_app_id != '-1'}></a><{/if}>
        <{/if}>
        <!--预售订单-->
         <{if $order.promotion_type == 'prepare'}>
          <{if $order.payinfo.pay_app_id != '-1'}><a href="#"><{/if}><{t}>等待付款<{/t}><{if $order.payinfo.pay_app_id != '-1'}></a><{/if}>
        <{/if}>
        <{switch from=$order.ship_status}>
        <{case value='1'}><{t}>[已发货]<{/t}>
        <{case value='2'}><{t}>[部分发货]<{/t}>
        <{case value='3'}><{t}>[部分退货]<{/t}>
        <{case value='4'}><{t}>[已退货]<{/t}>
        <{/switch}>
        <{/switch}>
        <{/switch}>
      </td>
      <td class="payments"><{$order.payinfo.pay_app_id|pay_name}></td>
      <td class="actions" valign="top"<{if $is_orders}> rowspan="2"<{/if}>>
        <!--普通订单-->
        <{if $order.status == 'active' && ($order.pay_status=='0' || $order.pay_status=='3') && $order.promotion_type != 'prepare'}>
          <{if $order.payinfo.pay_app_id != '-1' && $order.is_pay==0}>
          <a href="<{link app=b2c ctl=site_paycenter arg0=$order.order_id}>" class="btn btn-import"><span><span><{t}>去付款<{/t}></span></span></a>
          <{/if}>
          <{if $order.payinfo.pay_app_id != '-1' && $order.is_pay==1}>
          <a href="javascript:void(0);" onclick="js_method()" class="btn btn-grayed"><span><span><{t}>支付结果返回中<{/t}></span></span></a>
          <{/if}>
        <{/if}>

        <!--预售订单-->
        <{if $order.status == 'active' && $order.pay_status=='0' && $order.promotion_type == 'prepare' && $order.prepare.status=='true' && $order.prepare.begin_time < $order.prepare.nowtime &&  $order.prepare.nowtime < $order.prepare.end_time}>
          <{if $order.payinfo.pay_app_id != '-1' && $order.is_pay==0}>
          <a href="<{link app=b2c ctl=site_paycenter arg0=$order.order_id}>" class="btn btn-import"><span><span><{t}>去付订金<{/t}></span></span></a>
          <{/if}>
          <{if $order.payinfo.pay_app_id != '-1' && $order.is_pay==1}>
          <a href="javascript:void(0);" onclick="js_method()" class="btn btn-grayed"><span><span><{t}>支付结果返回中<{/t}></span></span></a>
          <{/if}>
        <{/if}>
        <!--预售订单-->
        <{if $order.status == 'active' && $order.pay_status=='3' && $order.promotion_type == 'prepare' && $order.prepare.status=='true' && $order.prepare.begin_time_final < $order.prepare.nowtime &&  $order.prepare.nowtime < $order.prepare.end_time_final}>
          <{if $order.payinfo.pay_app_id != '-1' && $order.is_pay==0}>
          <a href="<{link app=b2c ctl=site_paycenter arg0=$order.order_id}>" class="btn btn-import"><span><span><{t}>去付尾款<{/t}></span></span></a>
          <{/if}>
          <{if $order.payinfo.pay_app_id != '-1' && $order.is_pay==1}>
          <a href="javascript:void(0);" onclick="js_method()" class="btn btn-grayed"><span><span><{t}>支付结果返回中<{/t}></span></span></a>
          <{/if}>
        <{/if}>
        <!--预售订单-->
        <{if $order.status == 'active' && $order.pay_status=='3' && $order.promotion_type == 'prepare' && $order.prepare.status=='true' && $order.prepare.begin_time < $order.prepare.nowtime &&  $order.prepare.nowtime < $order.prepare.begin_time_final}>
          <{if $order.payinfo.pay_app_id != '-1' && $order.is_pay==1 }>
          <a href="javascript:void(0);" onclick="js_method()" class="btn btn-grayed"><span><span><{t}>支付结果返回中<{/t}></span></span></a>
          <{elseif $order.payinfo.pay_app_id != '-1' }>
          <a href="#" class="btn btn-import"><span><span><{t}>等待支付尾款<{/t}></span></span></a>
          <{/if}>
        <{/if}>

        <{if $order.status == 'active' && $order.pay_status!='1' && $order.promotion_type == 'prepare' && $order.prepare.status=='true' &&  $order.prepare.nowtime > $order.prepare.end_time_final}>
          <{if $order.payinfo.pay_app_id != '-1' && $order.is_pay==1 }>
          <span><span><{t}>支付结果返回中<{/t}></span></span>
          <{elseif $order.payinfo.pay_app_id != '-1' }>
          <span><span><{t}>支付尾款时间已过,请联系管理员进行退款<{/t}></span></span>
          <{/if}>
        <{/if}>
        <{if $order.status != 'dead' && $order.status != 'finish' && $order.ship_status =="1" && $order.received_status =='0'}>

        <!--=======================================================================================================================-->

          <a href="javascript:void(0);" class="btn btn-import" onclick="return receive('<{$order.url}>')"><span><span><{t}>确认收货<{/t}></span></span></a>
        <{/if}>
        <{if $order.status != 'dead' && $order.status != 'finish' && $order.ship_status =="2" && $order.received_status =='0'}>
        <a href="javascript:void(0);" class="btn btn-import disabled" onclick="error_show()"><span><span><{t}>确认收货<{/t}></span></span></a>
        <{/if}>
        <!--=======================================================================================================================-->
        
        <i class="separator"></i><a href="<{link app=b2c ctl=site_member act=orderdetail arg0=$order.order_id arg1=$archive}>"><{t}>查看订单<{/t}></a>

        <{if $order.status == 'active' && $order.pay_status == '0' && $order.ship_status == '0' && $order.promotion_type != 'prepare'}>
        <{if $order.is_pay == 0}>
        <i class="separator"></i><a class="btn-cancel" href="<{link app=b2c ctl=site_member act=cancel arg0=$order.order_id arg1=$archive}>"><{t}>取消订单<{/t}></a>
        <{/if}>
        <{else}>
        <i class="separator"></i><a href="<{link app=b2c ctl=site_member act=reAddCart arg0=$order.order_id arg1=$archive}>"><{t}>再次购买<{/t}></a>
        <{if $order.status == 'dead'}>
        <i class="separator"></i>
        <a href="javascript:if(confirm('删除以后将不会再看到该订单，是否继续？')) location='<{link app=b2c ctl=site_order act=dodelete arg0=$order.order_id}>'">
          <{t}>删除订单<{/t}></a>
        <{/if}>
        <{/if}>
        <{if $order.is_aftersales == true}>
        <i class="separator"></i><a href="<{link app=aftersales ctl=site_member act=add arg0=$order.order_id}>"><{t}>申请售后服务<{/t}></a>
        <{/if}>


      </td>
    </tr>
    <tr class="goods-row">
      <td colspan="5">
        <ul class="member-piclist">
          <{if $order.goods_items}>
          <{foreach from=$order.goods_items item=item_goods name=goods_item}>
          <!--goods-->
          <{if $item_goods.product}>
          <li class="goods-item">
            <div class="goods-pic" data-tips="<{$item_goods.product.name}>&nbsp;<{if $item_goods.product.attr}><{$item_goods.product.attr|spec_desc}><{/if}>&nbsp;<{$item_goods.product.quantity}>">
              <a href="<{$item_goods.product.link_url}>"><img src="<{$item_goods.product.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>" alt="<{$item_goods.product.name}>&nbsp;<{$item_goods.product.attr}>" data-img-zoom="true"></a>
            </div>
          </li>
          <{/if}>

          <!--adjunct-->
          <{if $item_goods.adjunct_items}>
          <{foreach from=$item_goods.adjunct_items item=item_adjunct name=adjunct_item}>
          <li class="goods-item">
            <div class="goods-pic" data-tips="<{$item_adjunct.name}><{if $item_adjunct.attr}>&nbsp;<{$item_adjunct.attr}><{/if}>&nbsp;<{$item_adjunct.quantity}>">
              <span class="label-important"><{t}>配<{/t}></span>
              <a href="<{link app=b2c ctl=site_product act=index arg0=$item_adjunct.products.product_id}>"><img src="<{$item_adjunct.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>" alt="<{$item_adjunct.name}> <{$item_adjunct.attr}>" data-img-zoom="true"></a>
            </div>
          </li>
          <{/foreach}>
          <{/if}>

          <!--gift-->
          <{if $item_goods.gift_items}>
          <{foreach from=$item_goods.gift_items item=item_gift name=gift_item}>
          <li class="goods-item">
            <div class="goods-pic" data-tips="<{$item_gift.name}>&nbsp;<{if $item_gift.attr}><{$item_gift.attr}><{/if}>&nbsp;<{$item_gift.quantity}>">
              <span class="label-important"><{t}>赠<{/t}></span>
              <a href="<{$item_gift.link_url}>"><img src="<{$item_gift.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>" alt="<{$item_adjunct.name}> <{$item_adjunct.attr}>" data-img-zoom="true"></a>
            </div>
          </li>
          <{/foreach}>
          <{/if}>
          <{/foreach}>
          <{/if}>
          <!-- gift -->
          <{if $order.order.gift_items}>
          <{foreach from=$order.order.gift_items item=item_gift name=gift_item}>
          <li class="goods-item">
            <div class="goods-pic" data-tips="<{$item_gift.name}>&nbsp;<{if $item_gift.attr}><{$item_gift.attr}><{/if}>&nbsp;<{$item_gift.quantity}>">
              <span class="label-important"><{t}>赠<{/t}></span>
              <a href="<{$item_gift.link_url}>"><img src="<{$item_gift.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>" alt="<{$item_adjunct.name}> <{$item_adjunct.attr}>" data-img-zoom="true"></a>
            </div>
          </li>
          <{/foreach}>
          <{/if}>
          <{if $order.gift.gift_items}>
          <{foreach from=$order.gift.gift_items item=item_gift name=gift_item}>
          <li class="goods-item">
            <div class="goods-pic" data-tips="<{$item_gift.name}>&nbsp;<{if $item_gift.attr}><{$item_gift.attr}><{/if}>&nbsp;<{$item_gift.quantity}>">
              <span class="label-important"><{t}>赠<{/t}></span>
              <a href="<{$item_gift.link_url}>"><img src="<{$item_gift.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>" alt="<{$item_adjunct.name}> <{$item_adjunct.attr}>" data-img-zoom="true"></a>
            </div>
          </li>
          <{/foreach}>
          <{/if}>

          <!-- extends -->
          <{if $order.extends_items}>
          <{foreach from=$order.extends_items item=item_extends name=item_extends}>
          <{$item_extends}>
          <{/foreach}>
          <{/if}>
        </ul>
      </td>
    </tr>
  </tbody>
  <{/foreach}>
  <{else}>
  <tbody class="first">
    <tr class="no-information"><td colspan="6">暂无订单</td></tr>
  </tbody>
  <{/if}>
</table>
<script>
function receive(url){
  var pingRequest = new Request({ 
    method: "post", 
    url:    url, 
    onSuccess:  function(rs){
      rs = JSON.decode(rs);
      if(rs){
        if(rs.error){
          Dialog.alert(rs.error);
          return false;
        }else{
          Dialog.alert(rs.success, {
            onClose: function() {
              location.reload();
            }
          });
          return true;
        }
      }else{
        return false;
      }
    }
    }); 
  pingRequest.send("url="+ url);
}
function error_show(){
  Dialog.alert("亲，您的商品还没发完呢");
}
</script>
